<%--
  Created by IntelliJ IDEA.
  User: 润
  Date: 2021/7/28
  Time: 0:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#insert").click(function () {
                var name=document.getElementById("name").value;
                var classId=document.getElementById("classId").value;
                var number=document.getElementById("number").value;
                var password=document.getElementById("password").value;
                var id=document.getElementById("id").value;
                if(name==""){
                    alert("输入不能为空！");
                }else {
                    var para= {

                        action:'queryAllStudent',

                        classId:classId
                    };
                    $.ajax({
                        type: "POST",
                        url: "http://localhost:8080/Anyview/StudentServlet?action=updateStudent",
                        data: {"classId":classId,"name":name,"number":number,"password":password,"id":id},
                        success: function (data) {
                            if (data.result2) {
                                alert("修改成功！");
                                window.location.href = "http://localhost:8080/Anyview/StudentServlet?"+$.param(para);
                            }
                        },
                        dataType: "json"
                    })


                } })

        })
    </script>

</head>
<body>
<div align="center">
    <form >
        名字:<input type="text" id="name" value="${requestScope.student.name}"><br><br>
        <input type="hidden" id="classId" value="${requestScope.student.classId}">
        <input type="hidden" id="number" value="${requestScope.student.username}">
        <input type="hidden" id="password" value="${requestScope.student.password}">
        <input type="hidden" id="id" value="${requestScope.student.id}">
        <input type="button" id="insert" value="确定">
    </form>
</div>
</body>
</html>
